package Screens;

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

import Main.GamePanel;
import Utils.Constantes;

import Botao.BotaoCreditos;
import Botao.BotaoPlay;
import Botao.BotaoTreinar;

public class TelaInicial extends Screen {
	BotaoPlay botao;
	BotaoTreinar botaoTreinar;
	BotaoCreditos botaoCredito;
	boolean tocaSom;

	public TelaInicial(int X, int Y, int Width, int Height, String fileNome) {
		super(X, Y, Width, Height, fileNome);
		
		botao= new BotaoPlay(270, 450, "/botoes/botao_jogar.png", "/botoes/botao_jogar_over.png");
		botaoTreinar = new BotaoTreinar(botao.x+botao.width+30, 450, "/botoes/botao_treinar.png", "/botoes/botao_trenar_over.png");
		botaoCredito = new BotaoCreditos(botaoTreinar.x+botaoTreinar.width+30, 450, "/botoes/botao_creditos.png", "/botoes/botao_creditos_over.png");
		tocaSom = false;
		
	}

	@Override
	public void Draw(Graphics2D dbg) {
		if(fundo!=null){
			dbg.drawImage(fundo, x, y, null);
			botao.Draw(dbg);
			botaoTreinar.Draw(dbg);
			botaoCredito.Draw(dbg);
		}
	}

	@Override
	public void Update(long diffTime) {
		botao.Update(diffTime);
		botaoTreinar.Update(diffTime);
		botaoCredito.Update(diffTime);
		if(GamePanel.TELA_ATIVA == GamePanel.TELA_INICIAL){
			if(!tocaSom){
				playSom();
				tocaSom = true;
			}
		}
	}
	
	@Override
	public void mouseMoved(MouseEvent e) {
		botao.mouseMoved(e);
		botaoTreinar.mouseMoved(e);
		botaoCredito.mouseMoved(e);
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		botao.mouseDragged(e);
		botaoTreinar.mouseDragged(e);
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		botao.mouseReleased(e);
	}

	@Override
	public void mousePressed(MouseEvent e) {
		botao.mousePressed(e);
		botaoTreinar.mousePressed(e);
		botaoCredito.mousePressed(e);
	}

	@Override
	public void mouseExited(MouseEvent e) {
		botao.mouseExited(e);
		botaoTreinar.mouseExited(e);
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		botao.mouseEntered(e);
		botaoTreinar.mouseEntered(e);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		botao.mouseClicked(e);
		botaoTreinar.mouseClicked(e);
		botaoCredito.mouseClicked(e);
	}

	@Override
	public void tratadorTecladoPress(KeyEvent e) {		
	}

	@Override
	public void tratadorTecladoReleased(KeyEvent e) {
	}

	@Override
	public void setaOpcao(int opcao) {
	}
	
	public void playSom(){
		Constantes.soundplayer.playTrack(Constantes.BGM_INTRO);
	}
}
